function(mit_unittest case)
  if(ARGC EQUAL 1)
    add_executable(${case} ${case}.cpp)
  else()
    add_executable(${ARGV})
  endif()
  if (case MATCHES "^test_.*")
    add_test(${case} ${case})
    set_tests_properties(${case} PROPERTIES TIMEOUT 300)
  endif()
  target_link_libraries(${case} PRIVATE -Wl,--whole-archive mock_di -Wl,--no-whole-archive oceanbase gtest gmock)
  target_include_directories(${case}
    PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/unittest ${CMAKE_SOURCE_DIR}/deps/oblib/unittest ${CMAKE_SOURCE_DIR}/sensitive_test)
endfunction()

function(mit_shared_storage_unittest case)
  mit_unittest(${case})
  if (case MATCHES "^test_.*")
    set_tests_properties(${case} PROPERTIES TIMEOUT 600)
  endif()
endfunction()

if(OB_BUILD_CLOSE_MODULES)
  mit_shared_storage_unittest(test_pcached_external_file_service)
  mit_shared_storage_unittest(test_sn_pcached_external_file_service)
  mit_shared_storage_unittest(test_disk_space_manager)
  mit_shared_storage_unittest(test_file_manager)
  mit_shared_storage_unittest(test_open_close)
  mit_shared_storage_unittest(test_ss_ha_prewarm_struct)
  mit_shared_storage_unittest(test_ss_mc_prewarm_struct)
  mit_shared_storage_unittest(test_ss_reader_writer)
  mit_shared_storage_unittest(test_ss_object_access_util)
  mit_shared_storage_unittest(test_device_config_mgr)
  mit_shared_storage_unittest(test_ss_preread_task)
  mit_shared_storage_unittest(test_sstable_private_object_cleaner)
  mit_shared_storage_unittest(test_clean_residual_data)
  mit_shared_storage_unittest(test_ddl_clog)
  mit_shared_storage_unittest(test_ss_fd_cache_perf)
  #mit_shared_storage_unittest(test_calibrate_disk_space) TODO(binifei.bnf): open this case later
  mit_shared_storage_unittest(test_segment_file_manager)
  mit_shared_storage_unittest(test_flush_unsealed_tmp_file)
  mit_shared_storage_unittest(test_ss_tmp_file_preread_flag)
  mit_shared_storage_unittest(test_auto_expand_disk)
  mit_shared_storage_unittest(test_ss_la_micro_key_manager)
  mit_shared_storage_unittest(test_ss_local_cache_service)
  mit_shared_storage_unittest(test_delete_remote_server_dir)
endif()

add_subdirectory(tmp_file)
add_subdirectory(simple_server)
add_subdirectory(atomic_protocol)
add_subdirectory(meta_service)
add_subdirectory(sslog)
add_subdirectory(ss_gc)
add_subdirectory(ss_micro_cache)
add_subdirectory(ss_macro_cache)
add_subdirectory(ss_mem_macro_cache)
add_subdirectory(share)
